package sentity

import (
	"path/filepath"
	"server/application/db/schema/dbops"

	"time"

	"gorm.io/gorm"
)

type UserAccount struct {
	ID              uint           `gorm:"primarykey;comment:ID"  json:"ID"  `
	Avatar          string         `gorm:"default:'';comment:头像1;type:varchar(100)" json:"avatar"`
	WechatOpenId    string         `gorm:"column:wechat_open_id;comment:微信公众号openid" json:"wechat_open_id"`
	MiniAppOpenId   string         `gorm:"column:mini_app_open_id;comment:小程序openid" json:"mini_app_open_id"`
	HuaweiUnionID   string         `gorm:"column:huawei_union_id;comment:华为unionid" json:"huawei_union_id"`
	HuaweiOpenid    string         `gorm:"column:huawei_openid;comment:华为openid" json:"huawei_openid"`
	Username        string         `gorm:"column:username;comment:用户名;" json:"username"`
	Password        string         `gorm:"column:password;comment:密码" json:"-"`
	Status          uint8          `gorm:"default:1;column:status;comment:状态" json:"status"`
	Phone           string         `gorm:"column:phone;comment:手机号" json:"phone"`
	Points          uint           `gorm:"default:0;column:points;comment:积分" json:"points" ` //积分
	HuaweiPushToken string         `gorm:"column:huawei_push_token;comment:华为推送token" json:"huawei_push_token"`
	VipEndAt        time.Time      `gorm:"column:vip_end_at;comment:vip到期时间" json:"vip_end_at"`
	VipPermanent    bool           `gorm:"column:vip_permanent;comment:是否为永久VIP" json:"vip_permanent"`
	IsCancel        bool           `gorm:"column:is_cancel;comment:是否已注销" json:"is_cancel"` //软注销
	CreatedAt       time.Time      `json:"created_at,omitempty"`
	UpdatedAt       time.Time      `json:"updated_at" `
	DeletedAt       gorm.DeletedAt `gorm:"index" json:"deleted_at"`
}

// GenConfig 生成相关配置
func (u UserAccount) GenConfig() dbops.EntityConfig {
	return dbops.EntityConfig{
		Title:             "用户",
		AsName:            "",                       //实体别名，请使用大驼峰命名法
		ViewsFatherFolder: filepath.Join("account"), //视图父目录
		TableName:         "user_account",
	}
}

// 表名
func (UserAccount) TableName() string {
	return "user_account"
}
